FROM python:3.11-slim

WORKDIR /app

# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 安装依赖
COPY requirements.txt .
RUN  pip install -U pip -i https://pypi.tuna.tsinghua.edu.cn/simple; \
    pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 复制应用代码
COPY . /app/

# 创建数据和日志目录
RUN mkdir -p /app/data /app/logs /app/config && \
    chmod +x docker-entrypoint.sh

# 设置环境变量
ENV CONFIG_FILE=/app/config/config.py
ENV DATA_DIR=/app/data
ENV LOGS_DIR=/app/logs
ENV PYTHONUNBUFFERED=1

# 入口点
ENTRYPOINT ["/app/docker-entrypoint.sh"]

CMD ["/app/config/config.py"]